package com.sunchen.asc.application.rest;

import com.sunchen.asc.service.common.ResultResponse;
import com.sunchen.asc.service.parameter.api.ParamService;
import com.sunchen.asc.service.parameter.vo.ParamVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/param")
public class ParamRest {

    @DubboReference
    private ParamService paramService;

    @ApiOperation(value = "创建参数")
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    public ResultResponse create(@RequestBody @ApiParam(name="参数vo",value="传入json格式",required=true) ParamVo paramVo){

        return paramService.create(paramVo);
    }

    @ApiOperation(value = "编辑参数")
    @RequestMapping(value = "/edit",method = RequestMethod.POST)
    public ResultResponse edit(@RequestBody @ApiParam(name="参数vo",value="传入json格式",required=true) ParamVo paramVo){

        return paramService.edit(paramVo);
    }

    @ApiOperation(value = "删除参数")
    @RequestMapping(value = "/delete",method = RequestMethod.GET)
    @ApiImplicitParam(name="id",value = "参数id",required = true)
    public ResultResponse delete(@RequestParam Long id){

        return paramService.delete(id);
    }

    @ApiOperation(value = "参数查询")
    @RequestMapping(value = "/get",method = RequestMethod.GET)
    @ApiImplicitParam(name="typeId",value = "参数类型id",required = true)
    public ResultResponse get(@RequestParam Long typeId){

        return paramService.get(typeId);
    }
}
